package com.evenmo.springjpademo.service;

import com.evenmo.springjpademo.entity.User;
import com.evenmo.springjpademo.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


/**
 * This is Description
 *
 * @author moyongjun
 * @date 2019/12/03
 */
@Service
public class UserService {
    @Autowired
    private UserRepository userRepository;


    public User findByUserName(String name){


        List<User> users=new ArrayList<>();
        try{
            users=userRepository.sleectByUserName(name);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
       return users.get(0);


    }
}
